package com.woniu.liuzhougov.itemAndTask.controller;


import com.woniu.liuzhougov.authorityControl.pojo.User;
import com.woniu.liuzhougov.itemAndTask.pojo.ItemsPojo;
import com.woniu.liuzhougov.itemAndTask.service.ItemApproveService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("ItemApproveManage")
public class ItemApproveController {

    @Autowired
    private ItemApproveService itemApproveService;


    /**
     * 添加事项审批结果
     * @param approvalRemark
     * @param approvalResult
     * @param itemId
     * @return
     */
    @RequestMapping("/ItemApproveCommit")
    @ResponseBody
    @RequiresPermissions(value = "approval_item")
    public String itemApproveCommit(String approvalRemark,Integer approvalResult,Integer itemId){
        User user = (User) SecurityUtils.getSubject().getPrincipal();  //从shiro中获取登录用户名称
        boolean b = itemApproveService.insertItemApproveResult(approvalRemark,approvalResult,user.getUserId(),itemId);
        if(b){
            //获取 立项人电话
            String userPhone = itemApproveService.selectItemFounderPhone(itemId);
            //获取 事项内容
            ItemsPojo item = itemApproveService.selectItemById(itemId);



            return "success";
        }
        return "loss";
    }


}
